public class DeadLockDemo {
    private static Object lockA = new Object();
    private static Object lockB = new Object();

    public static void main(String[] args) {
        new Thread(()->{
           synchronized (lockA){
               try {
                   System.out.println("获取A锁 成功.....");
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               synchronized (lockB){
                   System.out.println("获取B锁 死锁......");
               }
           }
        }).start();

        new Thread(()->{
            synchronized (lockB){
                System.out.println("获取B锁 死锁.....");
                synchronized (lockA){
                    System.out.println("获取A锁 死锁......");
                }
            }
        }).start();
    }
}
